package skdao

import (
	"Cgo/front/models"
	"Cgo/global"
	"errors"
)

type tyDao struct{}

var TyDao = tyDao{}

func (t tyDao) GetAllBooks() ([]models.SkBook, error) {
	var books []models.SkBook

	if r := global.DB.Raw("SELECT * FROM sk_book").Scan(&books); r.RowsAffected > 0 {
		return books, nil
	} else {
		return books, errors.New("没有查到数据")
	}
}
